package com.cqwu.util;

import java.io.UnsupportedEncodingException;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;

import com.opensymphony.xwork2.ActionSupport;
/**
 * 
* @Title: BaseAction
* @Description: 
* @Company: 鐗╄仈缃戜勘涔愰儴
* @author: lj
* @date: Nov 17, 2015 3:51:26 PM
 */
public abstract class BaseAction extends ActionSupport implements ServletRequestAware, ServletResponseAware {
	 
	 private static final long serialVersionUID = 1L;

	 public HttpServletRequest request;

	 public HttpServletResponse response;
	 
	 
	 public void setServletRequest(HttpServletRequest request) {
		 this.request = request;
	 }

	 public void setServletResponse(HttpServletResponse response) {
		 this.response = response;
	 }
	 
	 /**
	  * 鑾峰緱request
	  *
	  * @return
	 * @throws UnsupportedEncodingException 
	  */
	 public HttpServletRequest getRequest() {
	  return ServletActionContext.getRequest();
	 }

	 /**
	  * 鑾峰緱response
	  *
	  * @return
	  */
	 public HttpServletResponse getResponse() {
	  return ServletActionContext.getResponse();
	 }

	 /**
	  * 鑾峰緱session
	  *
	  * @return
	  */
	 public HttpSession getSession() {
	  return getRequest().getSession();
	 }

	 /**
	  * 鑾峰緱servlet涓婁笅鏂�	  *
	  * @return
	  */
	 public ServletContext getServletContext() {
	  return ServletActionContext.getServletContext();
	 }

	 public String getRealyPath(String path) {
	  return getServletContext().getRealPath(path);
	 }
	 
	}